<template>
    <view
        @tap="__e"
        @touchmove.stop.prevent="__e"
        class="mask data-v-4567adb5"
        :data-event-opts="[
            ['tap', [['cancel', ['$event']]]],
            ['touchmove', [['', ['$event']]]]
        ]"
    >
        <view @tap.stop.prevent="__e" class="mask-content data-v-4567adb5" :data-event-opts="[['tap', [['', ['$event']]]]]">
            <text @tap="__e" class="new-iconfont icon-close close-btn data-v-4567adb5" :data-event-opts="[['tap', [['cancel', ['$event']]]]]"></text>
            <view class="title data-v-4567adb5">提交发货</view>
            <view class="block data-v-4567adb5">
                <view class="item-title data-v-4567adb5">已选订单:</view>
                <view class="item-value data-v-4567adb5">{{ $root.g0 + '个' }}</view>
            </view>
            <view class="block data-v-4567adb5">
                <view class="item-title data-v-4567adb5">运费:</view>
                <view class="item-value data-v-4567adb5">{{ '￥' + $root.g1 }}</view>
            </view>
            <view class="block data-v-4567adb5">
                <view class="item-title data-v-4567adb5">可用优惠券:</view>
                <view @tap="__e" class="arrow-right bold data-v-4567adb5" :data-event-opts="[['tap', [['e0', ['$event']]]]]">
                    <text class="meta data-v-4567adb5" v-if="order.coupon_discount">{{ '- ¥' + $root.g2 }}</text>
                    <block v-else>
                        <text class="meta data-v-4567adb5" style="color: #ff1a1a" v-if="$root.g3">{{ $root.g4 + '张可用' }}</text>
                        <text class="meta gray-text data-v-4567adb5" v-else>暂无可用优惠券</text>
                    </block>
                    <text class="new-iconfont icon-arrow-right data-v-4567adb5"></text>
                </view>
            </view>
            <view class="data-v-4567adb5" style="height: 30rpx"></view>
            <select-address
                @__l="__l($event, { eventOpts: [['^input', [['__set_model', ['', 'address', '$event', []]]]]] })"
                @input="__e($event, { eventOpts: [['^input', [['__set_model', ['', 'address', '$event', []]]]]] })"
                class="address-c data-v-4567adb5"
                :data-event-opts="[['^input', [['__set_model', ['', 'address', '$event', []]]]]]"
                :value="address"
                vueId="4464aa6a-1"
            ></select-address>
            <view class="total data-v-4567adb5">
                总计：
                <price-display @__l="__l" class="data-v-4567adb5" :info="order" prefix="pay_" vueId="4464aa6a-2"></price-display>
            </view>
            <view class="tips data-v-4567adb5">{{ deliverTips }}</view>
            <view @tap="__e" class="button data-v-4567adb5" :data-event-opts="[['tap', [['submit', ['$event']]]]]">
                <text class="data-v-4567adb5">确认提交发货</text>
            </view>
        </view>
        <usable-coupon-popup
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['e1']]]
                    ]
                })
            "
            @change="
                __e($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['e1']]]
                    ]
                })
            "
            @close="
                __e($event, {
                    eventOpts: [
                        ['^change', [['couponChange']]],
                        ['^close', [['e1']]]
                    ]
                })
            "
            class="data-v-4567adb5"
            :data-event-opts="[
                ['^change', [['couponChange']]],
                ['^close', [['e1']]]
            ]"
            :unusableCoupons="unusableCoupons"
            :usableCoupons="usableCoupons"
            vueId="4464aa6a-3"
            v-if="isCouponPopup"
        ></usable-coupon-popup>
    </view>
</template>

<script>
import selectAddress from '@/components/SelectAddress/SelectAddress';
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import usableCouponPopup from '@/components/UsableCouponPopup/UsableCouponPopup';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/orderList/components/PayCard'],
    {
        '1ee6': function (e, n, t) {},
        '5a24': function (e, n, t) {
            'use strict';

            (function (e) {
                var o = t('4ea4');
                Object.defineProperty(n, '__esModule', {
                    value: true
                });
                n.default = void 0;
                var r = o(t('9523'));
                var i = o(t('82c0'));
                function s(e, n) {
                    var t = Object.keys(e);
                    if (Object.getOwnPropertySymbols) {
                        var o = Object.getOwnPropertySymbols(e);
                        if (n) {
                            o = o.filter(function (n) {
                                return Object.getOwnPropertyDescriptor(e, n).enumerable;
                            });
                        }
                        t.push.apply(t, o);
                    }
                    return t;
                }
                function c(e) {
                    for (var n = 1; n < arguments.length; n++) {
                        if (null != arguments[n]) {
                            var t = arguments[n];
                        } else {
                            var t = {};
                        }
                        if (n % 2) {
                            s(Object(t), true).forEach(function (n) {
                                (0, r.default)(e, n, t[n]);
                            });
                        } else {
                            Object.getOwnPropertyDescriptors
                                ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
                                : s(Object(t)).forEach(function (n) {
                                      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
                                  });
                        }
                    }
                    return e;
                }
                var u = {
                    components: {},
                    data: function () {
                        return {
                            address: {},
                            order: {},
                            carriage: 0,
                            unusableCoupons: [],
                            usableCoupons: [],
                            isCouponPopup: false,
                            currentCoupon: {}
                        };
                    },
                    props: {
                        selectedId: {
                            type: Array
                        }
                    },
                    computed: {
                        orderConfig: function () {
                            return this.$store.getters.setting.order || {};
                        },
                        deliverTips: function () {
                            return this.orderConfig.deliver_tips || '商品一经寄出，非质量问题不支持退换';
                        }
                    },
                    watch: {
                        address: function () {
                            this.initOrder();
                        }
                    },
                    onLoad: function (e) {},
                    created: function () {},
                    methods: {
                        couponChange: function (e) {
                            e.id === this.currentCoupon.id || ((this.currentCoupon = e), this.initOrder());
                        },
                        initOrder: function () {
                            var that = this;
                            if (!this.address.id) {
                                return false;
                            }
                            this.$http('/preview-deliver-orders', 'POST', {
                                order_ids: this.selectedId,
                                address_id: this.address.id,
                                coupon_id: this.currentCoupon.id
                            }).then(function (n) {
                                that.carriage = n.data.info.carriage;
                                that.order = n.data.info;
                                that.unusableCoupons = n.data.info.coupons.unusable;
                                that.usableCoupons = n.data.info.coupons.usable;
                            });
                        },
                        cancel: function () {
                            this.$emit('cancel');
                        },
                        submit: function () {
                            var that = this;
                            if (!this.address.id) {
                                e.showModal({
                                    title: '请选择收货地址'
                                });
                                return false;
                            }
                            e.showLoading({
                                title: '提交中',
                                icon: 'none'
                            });
                            this.$http('/deliver-orders', 'POST', {
                                order_ids: this.selectedId,
                                address_id: this.address.id,
                                coupon_id: this.currentCoupon.id
                            }).then(function (t) {
                                e.hideLoading();
                                var o = t.data;
                                o.is_need_pay
                                    ? i.default.pay(
                                          c(
                                              c({}, o),
                                              {},
                                              {
                                                  success: function () {
                                                      that.$emit('success');
                                                  },
                                                  fail: function () {
                                                      e.showToast({
                                                          title: '支付失败',
                                                          icon: 'none'
                                                      });
                                                      that.$http('/orders/'.concat(o.order.uuid), 'PUT', {
                                                          type: 'close_and_delete'
                                                      });
                                                  }
                                              }
                                          )
                                      )
                                    : that.$emit('success');
                            });
                        }
                    },
                    onPageScroll: function (e) {}
                };
                n.default = u;
            }.call(this, t('543d').default));
        },
        '8dd3': function (e, n, t) {
            'use strict';

            t.d(n, 'b', function () {
                return r;
            });
            t.d(n, 'c', function () {
                return i;
            });
            t.d(n, 'a', function () {
                return o;
            });
            var o = {
                SelectAddress: function () {
                    return t.e('components/SelectAddress/SelectAddress').then(t.bind(null, '8a38'));
                },
                PriceDisplay: function () {
                    return t.e('components/PriceDisplay/PriceDisplay').then(t.bind(null, '6b05'));
                },
                UsableCouponPopup: function () {
                    return t.e('components/UsableCouponPopup/UsableCouponPopup').then(t.bind(null, '3858'));
                }
            };
            var r = function () {
                var that = this;
                var n = (that.$createElement, that._self._c, that.selectedId.length);
                var t = that.$tool.formatPrice(that.carriage);
                if (that.order.coupon_discount) {
                    var o = that.$tool.formatPrice(that.order.coupon_discount);
                } else {
                    var o = null;
                }
                var r = that.order.coupon_discount ? null : that.usableCoupons.length;
                var i = !that.order.coupon_discount && r ? that.usableCoupons.length : null;
                that._isMounted ||
                    ((that.e0 = function (n) {
                        that.isCouponPopup = true;
                    }),
                    (that.e1 = function (n) {
                        that.isCouponPopup = false;
                    }));
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            g0: n,
                            g1: t,
                            g2: o,
                            g3: r,
                            g4: i
                        }
                    }
                );
            };
            var i = [];
        },
        ab6b: function (e, n, t) {
            'use strict';

            var o = t('1ee6');
            t.n(o).a;
        },
        cded: function (e, n, t) {
            'use strict';

            t.r(n);
            var o = t('5a24');
            var r = t.n(o);
            for (var i in o) {
                if (['default'].indexOf(i) < 0) {
                    (function (e) {
                        t.d(n, e, function () {
                            return o[e];
                        });
                    })(i);
                }
            }
            n.default = r.a;
        },
        ea74: function (e, n, t) {
            'use strict';

            t.r(n);
            var o = t('8dd3');
            var r = t('cded');
            for (var i in r) {
                if (['default'].indexOf(i) < 0) {
                    (function (e) {
                        t.d(n, e, function () {
                            return r[e];
                        });
                    })(i);
                }
            }
            t('ab6b');
            var s = t('f0c5');
            var c = Object(s.a)(r.default, o.b, o.c, false, null, '4567adb5', null, false, o.a, void 0);
            n.default = c.exports;
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'pages/orderList/components/PayCard-create-component',
    {
        'pages/orderList/components/PayCard-create-component': function (e, n, t) {
            t('543d').createComponent(t('ea74'));
        }
    },
    [['pages/orderList/components/PayCard-create-component']]
]);
</script>
<style>
@import './PayCard.css';
</style>
